package br.com.felix.fwt.ui;

import java.io.PrintWriter;

import org.apache.log4j.Logger;

import br.com.felix.fwt.log.LoggerFactory;
import br.com.felix.fwt.ui.exception.ComponentRenderException;


/**
 * The Class FileUploader implements HTML input type=file component.
 */
public class FileUploader extends Input {

	
	private static final long serialVersionUID = -536518141650881120L;

	private static Logger logger = LoggerFactory.getLogger(FileUploader.class);

	{
		this.cssClass = "fwtfileuploader";
	}

	public FileUploader() {
		super();
	}
	
	
	/* (non-Javadoc)
	 * @see br.com.felix.fwt.ui.Input#write(java.io.PrintWriter)
	 */
	@Override
	public void write(PrintWriter out) throws ComponentRenderException {
		if(!authorized()) return;
		out.write("\n<input type=\"file\" class=\"");
		out.write(cssClass);
		out.write("\" ");
		out.write(" name=\"");
		out.write(getName());

		String value = getValue();
		out.write("\" value=\"");
		if(value!=null)out.write(value);
		out.write("\"");
		if(style!=null)out.write(style);
		out.write(" />");

	}

}
